/**
 * @Description:
 * @author 云离
 * @date: 2020-02-06
 */
import React, { Component } from 'react'
import {Avatar, Col} from 'antd'
import { connect } from 'react-redux'
import PropTypes from "prop-types";
import {host} from '../../config/config'

const mapStateToProps = (state, ownProps) => {
    return {
        user: state.main.user
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
    }
}

class MyAvatar extends Component {

    static propTypes = {
        size: PropTypes.number.isRequired
    }

    render() {
        let img = `${host}/img/profile.jpg`
        const { user } = this.props
        if (user.avatar) {
            img = `${host}/profile/avatar/${user.avatar}`
        }
        return (
            <Avatar size={this.props.size} src={img}/>
        );
    }
}

export default connect(mapStateToProps,mapDispatchToProps)(MyAvatar)
